<template>
  <div>
    <!-- 导航栏 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>学生列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 表格 -->
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="name" label="姓名" width="180"></el-table-column>
      <el-table-column prop="class" label="班级" width="180"></el-table-column>
      <el-table-column prop="studentId" label="学号" width="180"></el-table-column>
      <el-table-column label="学习进度" width="200">
        <template #default="scope">
          <el-progress
              :percentage="scope.row.progress"
              :color="getProgressColor(scope.row.progress)"
          ></el-progress>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页器 -->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.length"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        // 示例数据
        { name: '张三', class: '一班', studentId: '2023001', progress: 60 },
        { name: '李四', class: '二班', studentId: '2023002', progress: 80 },
        { name: '宋人头', class: '二班', studentId: '2023003', progress: 75 },
        { name: '基头四', class: '二班', studentId: '2023004', progress: 70 },
        { name: '梅梁新', class: '二班', studentId: '2023005', progress: 80 },
        { name: '甄羔宵', class: '二班', studentId: '2023006', progress: 65 },
        { name: '可莉（陈浩贤）', class: '二班', studentId: '2023007', progress: 95 },
        { name: '南梁北朝', class: '二班', studentId: '2023008', progress: 88 },
        { name: '甄夏头', class: '二班', studentId: '2023006', progress: 65 },
        { name: '梅坂乏', class: '二班', studentId: '2023006', progress: 77 },
        // ... 其他学生数据
      ],
      currentPage: 1,
      pageSize: 10,
    };
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      this.currentPage = val;
    },
    // 根据进度返回颜色
    getProgressColor(progress) {
      if (progress < 30) {
        return 'red';
      } else if (progress < 70) {
        return 'orange';
      } else {
        return 'green';
      }
    },
    // 注意：Element Plus 的 Progress 组件没有直接使用 `:status` 属性来改变颜色，因此上面的 `getStatus` 方法未被使用。
  },
};
</script>

<style scoped>
/* 样式代码可以根据需要添加 */
</style>